import request from "../utils/unirequest";
import type { LuchResponse } from '../type/common';
import type { ISysMaterial, ISysMaterialQuery, ISysNotification, ISysMaterialGroupQuery } from '../components/XenMaterialPicker/type/interface';
import type { IFrameworkUser, QueryTimeline, WorkflowInfo, ISysHrTransferRequestBill, ICompanyItem } from "../type/common";
export default function commonApi() {
  return {
    // 获取框架用户
    async GetFrameworkUsers(): Promise<IFrameworkUser[]> {
      return await request.get("/api/SysWechatUser/GetFrameworkUsers");
    },
    // 部门选择列表
    async GetSysGroups(): Promise<IFrameworkUser[]> {
      return await request.get("/api/SysVisitorRecordRequestBill/GetSysGroups")
    },
    // 获取事由选择列表
    async GetSysVisitorReasons(): Promise<IFrameworkUser[]> {
      return await request.get("/api/SysVisitorRecordRequestBill/GetSysVisitorReasons")
    },
    // 时间线
    async getTimeline(params: QueryTimeline): Promise<WorkflowInfo[]> {
      return await request.get("/api/common/gettimeline", { params })
    },
    // 获取部门树
    GetParentsTree: (auth: boolean = false): Promise<ISysHrTransferRequestBill[]> =>
      request.get(`/api/common/GetGroups?auth=${auth}`),
    // 获取公司列表
    GetUserCompanies: (auth: boolean = true): Promise<ICompanyItem[]> =>
      request.get(`/api/common/GetUserCompanies?auth=${auth}`),
    // 获取物料列表
    GetMaterialList: (data: ISysMaterialQuery): Promise<LuchResponse<ISysMaterial[]>> =>
      request.post(`/api/SysMaterial/Search`, data),
    // 获取物料组列表
    GetMaterialGroupList: (data: ISysMaterialGroupQuery): Promise<LuchResponse<ISysNotification[]>> =>
      request.post(`/api/SysMaterialAttribute/Search`, data),
    // 获取文件名
    GetFileName: async (fileId: string): Promise<string> => {
      return await request.get(`/api/_file/GetFileName/${fileId}`);
    }
  };
}

